<template>
  <div>
    <home-header :city="city"></home-header>
    <home-swiper :imglist="imglist"></home-swiper>
    <home-icons :iconslist="iconslist"></home-icons>
    <home-hot :hotGoods="hotGoods"></home-hot>
    <home-like :likeGoods="likeGoods"></home-like>
    <home-weekend :weekendGoods="weekendGoods"></home-weekend>
    <home-footer></home-footer>
  </div>
</template>

<script>
import HomeHeader from "./components/header";
import HomeSwiper from "./components/swiper";
import HomeIcons from "./components/icons";
import HomeHot from "./components/hot";
import HomeLike from "./components/like";
import HomeWeekend from "./components/weekend";
import HomeFooter from "./components/footer";
import axios from "axios";

export default {
  name: "Home",
  data() {
    return {
      city: "",
      imglist: [],
      iconslist: [],
      likeGoods: [],
      hotGoods: [],
      weekendGoods: []
    };
  },
  components: {
    HomeHeader,
    HomeSwiper,
    HomeIcons,
    HomeHot,
    HomeLike,
    HomeWeekend,
    HomeFooter
  },
  methods: {
    getHomeInfo() {
      axios.get("/api/index.json").then(this.getHomeInfoSucc);
    },
    getHomeInfoSucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        this.city = data.city;
        this.imglist = data.imglist;
        this.iconslist = data.iconslist;
        this.likeGoods = data.likeGoods;
        this.hotGoods = data.hotGoods;
        this.weekendGoods = data.weekendGoods;
      }
    }
  },
  mounted() {
    this.getHomeInfo();
  }
};
</script>

<style scoped>
</style>